//
//  LSMinePersonalEntranceCell.m
//  LaSaCivilAffairsDepartment
//
//  Created by 聂志康 on 2018/12/19.
//  Copyright © 2018 wpkj. All rights reserved.
//

#import "LSMinePersonalEntranceCell.h"

@interface LSMinePersonalEntranceCell ()
@property (nonatomic, strong) UIView *customerContentView;
@property (nonatomic, strong) UIImageView *userIconImageView;
@property (nonatomic, strong) UILabel *userNickNameLabel;
@property (nonatomic, strong) UILabel *userNameLabel;
@property (nonatomic, strong) UIImageView *rightArrowImageView;
@end

@implementation LSMinePersonalEntranceCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = hexColor(EEEEEE);
        [self.contentView addSubview:self.customerContentView];
        [self.customerContentView addSubview:self.userIconImageView];
        [self.customerContentView addSubview:self.userNickNameLabel];
        [self.customerContentView addSubview:self.userNameLabel];
        [self.customerContentView addSubview:self.rightArrowImageView];
    }
    return self;
}

- (void)setImageName:(NSString *)imageName {
    _imageName = imageName;
    self.userIconImageView.image = [UIImage imageNamed:imageName];
}

- (void)setUserNickName:(NSString *)userNickName {
    _userNickName = userNickName;
    self.userNickNameLabel.text = [NSString stringWithFormat:@"登录账号：%@",userNickName];
}

- (void)setUserMobile:(NSString *)userMobile {
    _userMobile = userMobile;
    self.userNameLabel.text = [NSString stringWithFormat:@"手机号：%@",userMobile];
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated {
    [super setHighlighted:highlighted animated:animated];
    WS
    if (highlighted) {
        if (animated) {
            [UIView animateWithDuration:0.5 animations:^{
                [weakSelf.customerContentView setBackgroundColor:hexColor(d9d9d9)];
            }];
        } else {
            [weakSelf.customerContentView setBackgroundColor:hexColor(d9d9d9)];
        }
    } else {
        if (animated) {
            [UIView animateWithDuration:0.5 animations:^{
                [weakSelf.customerContentView setBackgroundColor:UIColor.whiteColor];
            }];
        } else {
            [weakSelf.customerContentView setBackgroundColor:UIColor.whiteColor];
        }
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    WS
    if (selected) {
        if (animated) {
            [UIView animateWithDuration:0.5 animations:^{
                [weakSelf.customerContentView setBackgroundColor:hexColor(d9d9d9)];
            }];
        } else {
            [weakSelf.customerContentView setBackgroundColor:hexColor(d9d9d9)];
        }
    } else {
        if (animated) {
            [UIView animateWithDuration:0.5 animations:^{
                [weakSelf.customerContentView setBackgroundColor:UIColor.whiteColor];
            }];
        } else {
            [weakSelf.customerContentView setBackgroundColor:UIColor.whiteColor];
        }
    }
}

- (UIImageView *)userIconImageView {
    if (!_userIconImageView) {
        _userIconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(15,10, 80, 80)];
        _userIconImageView.layer.cornerRadius = 5;
        _userIconImageView.layer.masksToBounds = true;
    }
    return _userIconImageView;
}

- (UILabel *)userNickNameLabel {
    if (!_userNickNameLabel) {
        _userNickNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(95+10, 10, ScreenWidth-90-40, 40)];
        _userNickNameLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:15];
        _userNickNameLabel.textColor = hexColor(333333);
    }
    return _userNickNameLabel;
}

- (UILabel *)userNameLabel {
    if (!_userNameLabel) {
        _userNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(95+10, 10+40, ScreenWidth-90-40, 40)];
        _userNameLabel.font = [UIFont fontWithName:@"SourceHanSansCN-Regular" size:15];
        _userNameLabel.textColor = hexColor(333333);
    }
    return _userNameLabel;
}

- (UIImageView *)rightArrowImageView {
    if (!_rightArrowImageView) {
        _rightArrowImageView = [[UIImageView alloc] initWithImage:[[UIImage imageNamed:@"jiantou"] changeWithNewTintColor:hexColor(999999)]];
        _rightArrowImageView.center = CGPointMake(ScreenWidth-20, LSMinePersonalEntranceCellHeight/2);
    }
    return _rightArrowImageView;
}

- (UIView *)customerContentView {
    if (!_customerContentView) {
        _customerContentView = [[UIView alloc] initWithFrame:CGRectMake(0, 15, ScreenWidth, LSMinePersonalEntranceCellHeight)];
        _customerContentView.backgroundColor = UIColor.whiteColor;
    }
    return _customerContentView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

@end
